import java.util.Random;
import java.util.Scanner;

public class test17 {
    public static void main(String[] args) {
        //1.生成随机数
        Random rand = new Random(); //创建对象
        int num = rand.nextInt(100)+1;//生成随机数
        //2.键盘录入,猜数字
        Scanner sc = new Scanner(System.in);
        //3.开始判断
        while(true){
        System.out.println("输入一个数字");
        int guess = sc.nextInt();
            if(guess>num){
                System.out.println("猜大了");
            }
            else if(guess<num){
                System.out.println("猜小了");
            }
            else if(guess==num)
            {
                System.out.println("猜对了");
                break;
            }
        }
    }
}
